package com.my.attendance.service;

import com.my.attendance.dao.UserDao;
import com.my.attendance.entity.Attendance;
import com.my.attendance.entity.Employee;

import java.util.Date;

public class UserService {
    private UserDao userDao=new UserDao();
    public Employee checkLogin(String employee_Number, String password) throws Exception{
        return userDao.checkLogin(employee_Number,password);

    }


    public void gowork(Attendance attendance) throws Exception{
        userDao.gowork(attendance);
    }

    public void outwork(Attendance attendance) throws Exception{
        userDao.outwork(attendance);
    }

    public void SignUser(Attendance attendance) throws Exception{
        userDao.SignUser(attendance);
    }

    public void OutUser(Attendance attendance) throws Exception {
        userDao.OutUser(attendance);
    }

    public boolean CheckOut(String employee_number, Date day) throws Exception{
        Attendance attendance=userDao.checkWork(employee_number,day);
        return attendance.getEnd_type().equals("未签到");
    }

    public boolean checkSign(String employee_number, Date day) throws Exception {
        Attendance attendance = userDao.checkWork(employee_number,day);
        return (attendance.getStart_type().equals("未签到") && attendance.getEnd_type().equals("未签到"));
    }
}
